# coding=utf-8
class LL1Parser:
    def __init__(self, text):
        self.text = text
        self.pos = 0
        self.current_char = None
        self.next_char()
    
    def next_char(self):
        """移动到下一个字符"""
        if self.pos < len(self.text):
            self.current_char = self.text[self.pos]
            self.pos += 1
        else:
            self.current_char = None
    
    def eat(self, char):
        """匹配当前字符并移动到下一个字符"""
        if self.current_char == char:
            self.next_char()
        else:
            raise SyntaxError(f"Expected '{char}', got '{self.current_char}'")
    
    def parse(self):
        """开始语法分析"""
        try:
            self.E()
            # 确保下一个字符是#或到达文件末尾
            if self.current_char == '#':
                self.eat('#')
                # 确保#之后没有其他字符
                return self.current_char is None
            else:
                return False
        except SyntaxError:
            return False
    
    def E(self):
        """E → TE1"""
        self.T()
        self.E1()
    
    def E1(self):
        """E1→+TE1 | ε"""
        if self.current_char == '+':
            self.eat('+')
            self.T()
            self.E1()
        # 空产生式，什么都不做
    
    def T(self):
        """T → FT1"""
        self.F()
        self.T1()
    
    def T1(self):
        """T1→*FT1 | ε"""
        if self.current_char == '*':
            self.eat('*')
            self.F()
            self.T1()
        # 空产生式，什么都不做
    
    def F(self):
        """F→(E)|i"""
        if self.current_char == '(':
            self.eat('(')
            self.E()
            self.eat(')')
        elif self.current_char == 'i':
            self.eat('i')
        else:
            raise SyntaxError(f"Expected '(' or 'i', got '{self.current_char}'")
 
def is_valid_expression(text):
    """检查表达式是否有效"""
    # 首先检查字符是否只包含允许的符号
    valid_chars = set('i+*()#')
    if not all(c in valid_chars for c in text):
        return False
    
    # 使用LL(1)解析器进行语法分析
    parser = LL1Parser(text)
    return parser.parse()
 
# 处理输入
try:
    while True:
        line = input().strip()
        if is_valid_expression(line):
            print("syntax correct")
        else:
            print("syntax error")
except EOFError:
    pass
except Exception:
    print("syntax error")
